package com.ruoyi.system.controller;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.service.SysAssetDepreciationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 资产折旧Controller
 *
 * @author zlz
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/depreciation")
public class SysAssetDepreciationController {
    @Autowired
    private SysAssetDepreciationService sysAssetDepreciationService;


    /**
     *
     * @param type 折旧方法（必传），1-年限平均法，2-双倍余额递减法，3-年数总和法
     * @param year 预计尚可使用年限，年数总和法必传
     * @param assetId 资产id，必传
     * @return
     */
    @RequiresPermissions("system:depreciation:value")
    @GetMapping("/value")
    public AjaxResult getAssetDepreciationValue(@RequestParam (value = "type", required = true) Integer type,
                                                @RequestParam (value = "year", required = false) Integer year,
                                                @RequestParam (value = "assetId", required = true) Long assetId) throws Exception {
        return AjaxResult.success(sysAssetDepreciationService.getAssetDepreciationValue(assetId,type,year));
    }
}
